# import pandas as pd
# from elasticsearch import Elasticsearch, helpers
# from datetime import datetime
#
# # Elasticsearch连接配置
# es = Elasticsearch("http://10.206.60.14:9200")
# csv_path = '/Users/chongwen/Downloads/裁判文书全量数据（已完成）/2021年裁判文书数据_马克数据网/2021年08月裁判文书数据.csv'
#
# df = pd.read_csv(csv_path)
#
#
# # 准备数据批量导入Elasticsearch
# def generate_data(df):
#     for index, row in df.iterrows():
#         # 使用dict构造器与字典推导式处理每一行，将所有NaN值转换为None
#         yield {
#             "_index": "case_index",
#             "_source": {
#                 "original_link": None if pd.isnull(row['原始链接']) else row['原始链接'],
#                 "case_number": None if pd.isnull(row['案号']) else row['案号'],
#                 "case_name": None if pd.isnull(row['案件名称']) else row['案件名称'],
#                 "court": None if pd.isnull(row['法院']) else row['法院'],
#                 "region": None if pd.isnull(row['所属地区']) else row['所属地区'],
#                 "case_type": None if pd.isnull(row['案件类型']) else row['案件类型'],
#                 "case_type_code": None if pd.isnull(row['案件类型编码']) else row['案件类型编码'],
#                 "source": None if pd.isnull(row['来源']) else row['来源'],
#                 "trial_procedure": None if pd.isnull(row['审理程序']) else row['审理程序'],
#                 "judgment_date": None if pd.isnull(row['裁判日期']) else row['裁判日期'],
#                 "publication_date": None if pd.isnull(row['公开日期']) else row['公开日期'],
#                 "parties": None if pd.isnull(row['当事人']) else row['当事人'],
#                 "case_reason": None if pd.isnull(row['案由']) else row['案由'],
#                 "legal_basis": None if pd.isnull(row['法律依据']) else row['法律依据'],
#                 "full_text": None if pd.isnull(row['全文']) else row['全文'],
#             }
#         }
#
#
#
# # 批量导入数据到Elasticsearch
# helpers.bulk(es, generate_data(df))
#
# print("数据导入完成")
#
